﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FrienDev.BusinessRules;
using FrienDev.Data;

public partial class Controls_Users_RulesEdit : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitUserPrivacySetting();
        }
        bt_Save.Click += new EventHandler(bt_Save_Click);
    }

    void bt_Save_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(1000);
        string ps = ddl_DefaultPage.SelectedValue + "-" + ddl_RecentVistList.SelectedValue + "-" + ddl_FriendsList.SelectedValue + "-" + ddl_ProfileBasicInfo.SelectedValue + "-" + ddl_ProfileDetailInfo.SelectedValue
            + "-" + ddl_MSN.SelectedValue + "-" + ddl_QQ.SelectedValue + "-" + ddl_Telephone.SelectedValue + "-" + ddl_MobilePhone.SelectedValue + "-" + ddl_Fax.SelectedValue + "-" + ddl_Track.SelectedValue;
        UserRules.Instance.UpdateUserPrivacySetting(ps);
        up_UserRulesForm.Update();
    }

    private void InitUserPrivacySetting()
    {
        User user = UserRules.Instance.GetCurrentUser();
        if (!string.IsNullOrEmpty(user.PrivacySettings))
        {
            string[] ps = user.PrivacySettings.Split('-');
            ddl_DefaultPage.SelectedValue = ps[0];
            ddl_RecentVistList.SelectedValue = ps[1];
            ddl_FriendsList.SelectedValue = ps[2];
            ddl_ProfileBasicInfo.SelectedValue = ps[3];
            ddl_ProfileDetailInfo.SelectedValue = ps[4];
            ddl_MSN.SelectedValue = ps[5];
            ddl_QQ.SelectedValue = ps[6];
            ddl_Telephone.SelectedValue = ps[7];
            ddl_MobilePhone.SelectedValue = ps[8];
            ddl_Fax.SelectedValue = ps[9];
            ddl_Track.SelectedValue = ps[10];
        }
    }
}